from __future__ import division
from functions import *
from utils import *
from gevi_classes import *
%matplotlib inline
%load_ext autoreload
%autoreload 2
%%javascript
IPython.OutputArea.auto_scroll_threshold = 1000;
# instantiate utility class
gr = Graph()
Data collected in 5 X 1min, with 1min pause in between 2921 images obtained in 60s
username = os.path.expanduser('~').split('/')[-1]
if username == "GP1514":
print("At Imperial")
mouseAPath = '/Volumes/DATA/DATA/Equalized Separation/2014 Oct 27/'
mouseBPath = '/Volumes/DATA/DATA/Equalized Separation/2014 Oct 22/'
mouseCPath = '/Volumes/DATA/DATA/Equalized Separation/2014 Oct 22/'
else:
print("Using laptop")
mouseAPath = '/Users/guillaume/Projects/GEVI-DATA/2014 Oct 27/'
mouseBPath = '/Users/guillaume/Projects/GEVI-DATA/2014 Oct 22/'
mouseCPath = '/Users/guillaume/Projects/GEVI-DATA/2014 Oct 28/'
discard = {
'MouseA':
{
3 : [0,1],
4 : [1,2],
5 : [2],
6 : [2,3,4]
},
'MouseB' :
{
3 : [2,4,5],
4 : [1,2]
}
}
# my choice
discard = {
'MouseA':
{
3 : [0,1,3],
# 4 : [],
# 5 : [],
6 : [1]
},
'MouseB' :
{
3 : [1,4],
# 4 : []
},
'MouseC' :
{}
}
mouseA = Mouse('mouseA', mouseAPath, [3,4,5,6],discard['MouseA'] )
mouseB = Mouse('mouseB', mouseBPath, [2,3,4,5],discard['MouseB'] )
mouseC = Mouse('mouseC', mouseCPath, [4],discard['MouseC'] )
# filtering parameters
# mouseA.minFreqAlpha = 1
# mouseA.maxFreqAlpha = 200
mouseB.minFreqAlpha = 1
mouseB.maxFreqAlpha = 200
mouseA.window = 10
gr.fHmax = 30
gr.fRmax = 200
# mouseA.loadData()
mouseB.loadData()
# mouseC.loadData()
r = mouseB.experiments[0].repeats[0].ratio
h = mouseB.experiments[0].repeats[0].hemo
m = mouseB.experiments[0].repeats[0].mask
r.shape
fig = plt.figure()
ax = fig.add_subplot(131)
ax.imshow(m)
ax.set_title('rep 1, exp 2 , mouseB')
ax = fig.add_subplot(132)
ax.imshow(mouseB.experiments[0].expMask)
ax.set_title('mean all repeats')
ax = fig.add_subplot(133)
mouseB.setMask()
ax.imshow(mouseB.mouseMask)
ax.set_title('mouseB')
fig = plt.figure()
ax = fig.add_subplot(121)
ax.imshow(mouseB.experiments[0].ratioMasked[1][0])
ax.set_title('Masked ratio')
ax = fig.add_subplot(122)
ax.imshow(mouseB.experiments[0].hemoMasked[1][0])
ax.set_title('Masked hemo')
plt.figure()
x = xax(mouseB.experiments[0].repeats[0].mHemo[0:200],int(60000*200/2912))
ax1 = plt.subplot2grid((1,3), (0,0), colspan=2)
ax2 = plt.subplot2grid((1,3), (0,2))
ax1.plot(x,mouseB.experiments[0].repeats[0].mRatio[0:200], label='ratio')
ax1.plot(x,mouseB.experiments[0].repeats[0].mRatioUnmasked[0:200], label='outside masked ratio')
ax1.plot(x,mouseB.experiments[0].repeats[0].mRatioMasked[0:200], label='masked ratio')
ax1.legend(loc='best')
ax1.set_title('mean ratio vs mean masked ratio vs outside mask')
ax2.imshow(mouseB.experiments[0].repeats[0].mask)
ax2.set_title('Mask')
plt.figure()
ax1 = plt.subplot2grid((1,3), (0,0), colspan=2)
ax2 = plt.subplot2grid((1,3), (0,2))
ax1.plot(x,mouseB.experiments[0].repeats[0].mHemo[0:200], label='ratio')
ax1.plot(x,mouseB.experiments[0].repeats[0].mHemoUnmasked[0:200], label='outside masked hemo')
ax1.plot(x,mouseB.experiments[0].repeats[0].mHemoMasked[0:200], label='masked hemo')
ax1.legend(loc='best')
ax1.set_title('mean hemo vs mean masked hemo vs outside mask')
ax2.imshow(mouseB.experiments[0].repeats[0].mask)
ax2.set_title('Mask')
# alpha
plt.figure()
x = xax(mouseB.experiments[0].repeats[0].alpha,60000)
plt.plot(x,mouseB.experiments[0].repeats[0].alpha, label='alpha')
plt.plot(x,mouseB.experiments[0].repeats[0].alphaUnmasked, label='outside masked alpha')
plt.plot(x,mouseB.experiments[0].repeats[0].alphaMasked, label='masked alpha')
plt.legend(loc='best')
plt.title('mean ratio vs mean masked alpha')
al = np.fft.ifft(np.fft.fft(mouseB.experiments[0].repeats[0].mHemo)/ \
np.fft.fft(mouseB.experiments[0].repeats[0].mRatio))
plt.plot(movingaverage(al,10))
alu = np.fft.ifft(np.fft.fft(mouseB.experiments[0].repeats[0].mHemoUnmasked)/ \
np.fft.fft(mouseB.experiments[0].repeats[0].mRatioUnmasked))
plt.plot(movingaverage(alu,10))
alm = np.fft.ifft(np.fft.fft(mouseB.experiments[0].repeats[0].mHemoMasked)/ \
np.fft.fft(mouseB.experiments[0].repeats[0].mRatioMasked))
plt.plot(movingaverage(alm,10))
plt.figure()
plt.imshow(maskfn(mouseB.experiments[0].repeats[0].ratio, mouseB.experiments[0].repeats[0].mask )[0])
gr.plotTF(mouseB,mask=True)
gr.plotTF(mouseB,mask=False)